<script>
        var issendMsg = 1;
        function sendphoncode() {
            var phone = $('#phone').val();
         var mobile = /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(16[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})|(19[0-9]{9})$/;
            if (!phone || !mobile.test(phone)) {
                layer.tips('请输入正确的手机号码', '#phone', { time: 1000, tips: [1,'#dd2727'] });
            } else {
                if (issendMsg) {
                    issendMsg = 0;
					var index = layer.load(2, {time: 10*1000});
                    $.ajax({
                        type: "post",
                        url: "{:U('Ajax/sendmsg4')}",
                        dataType: 'json',
                        data: {phone: phone},
                        success: function (data) {
                            if (data['status']) {
                                layer.msg(data['info'], {icon: 6});
                                timecount(60);
                            } else {
								 issendMsg = 1;
                                layer.msg(data['info'], {icon: 5});
                            }
							layer.close(index); 
                        }
                    });
                }
            }
        }
        /**
         * 倒计时
         * @param start
         */
     var start=60;  
	function timecount(start) {
        if (start == 0) {
            $('#sendMsg').val('获取手机验证码');
            issendMsg = 1;
			 start--;
          
        } else {
            $('#sendMsg').val('已发送' + start + '秒');
			issendMsg = 0;
            start--;
        }
		if(start>-1){
        setTimeout(function () {
            timecount(start)
        }, 1000);
		}
		
    }
		
		
    </script>